<template>
  <div class="photoinfo-body">
    <h3>{{photoinfo.title}}</h3>
    <p class="subtitle">
      <span>发表的时间:{{photoinfo.add_time|dateFormat('YYYY-MM-DD hh:mm:ss')}}</span>
      <span>点击:{{photoinfo.click}} 次</span>
    </p>
    <hr>
    <!-- 缩略图 -->
    <div>
      <vue-preview :slides="list" class="thumbs"></vue-preview>
    </div>
    <!-- 图片内容区域 -->
    <div v-html="photoinfo.content" class="content"></div>
    <!-- 评论区域 -->
    <cmt-box :id="id"> </cmt-box>
  </div>
  
</template>

<script>
//导入评论模块
import comment from '../suncomponents/comment.vue'

export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfo: {},

      list: []
    };
  },
  created() {
    this.getPhotoInfo(), this.getThumimages();
  },
  methods: {
    getPhotoInfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(result => {
        if (result.body.status === 0) {
          // console.log(123);
          //   console.log(result.body);
          this.photoinfo = result.body.message[0];
        }
      });
    },
    getThumimages() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        if (result.body.status === 0) {
          console.log(result.body);
          result.body.message.forEach(item => {
            item.w = 600;
            item.h = 400;
            item.msrc = item.src;
          });
          this.list = result.body.message;
        }
      });
    }
  },
  components:{
    //注册评论组件
    "cmt-box":comment
  }
  
};
</script>

<style lang='scss'>
.photoinfo-body {
  h3 {
    color: blue;
    font-size: 14px;
    text-align: center;
    margin: 15px 0;
  }
  .subtitle {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
  }
  .content {
    font-size: 14px;
    line-height: 30px;
  }

  .thumbs {
    .my-gallery {
      display: flex;
      flex-wrap: wrap;
      figure {
        margin: 10px;
        box-shadow: 0 0 10px #999;
        img {
          width: 100px;
          vertical-align: middle;
        }
      }
    }
  }
}
</style>
